<template>
  <div class="topic">
    <div class="topic_title">专题精选</div>
    <van-swipe :loop="false" :show-indicators="false">
      <van-swipe-item v-for="item in topicListarr" :key="item.id">
        <img :src="item.scene_pic_url" alt />
        <div>
          {{item.title}}
          <span>￥{{item.price_info | priceFilter}}元起</span>
        </div>
        <p>{{item.subtitle}}</p>
      </van-swipe-item>
    </van-swipe>
  </div>
</template>

<script>
export default {
  props: {
    topicListarr: {
      type: Array,
      default: []
    }
  },
  filters: {
    // 价格过滤器，所有价格保留两位小数
    priceFilter(money) {
      return money.toFixed(2);
    }
  }
};
</script>

<style lang="less">
.topic {
  background: #fff;
  margin-bottom: 10px;
  .topic_title {
    height: 50px;
    line-height: 50px;
    text-align: center;
  }
  .van-swipe {
    width: 98%;
    .van-swipe__track {
      .van-swipe-item {
        display: block;
        padding-left: 10px;
        box-sizing: border-box;
        img {
          width: 100%;
          height: 193px;
        }
        div {
          margin-top: 10px;
          span {
            color: darkred;
          }
        }
        p {
          line-height: 30px;
          color: #666;
          font-size: 12px;
          width: 100%;
          text-overflow: ellipsis;
          white-space: nowrap;
          overflow: hidden;
          margin: 0;
        }
        &:last-child {
          padding-right: 10px;
        }
      }
    }
  }
}
</style>